package main

import (
	"fmt"
	"sync"
	"time"
)

var wg sync.WaitGroup

func download(url string) {
	fmt.Println("download", url)
	time.Sleep(time.Second)
	wg.Done() //减去一个计数
}

func main() {
	for i := 0; i < 3; i++ {
		wg.Add(1) //为 wg 添加一个计数
		n := string(i + 'a')
		go download("abc.com/" + n)
	}

	wg.Wait() //等待所有的协程执行结束
	fmt.Println("done!")
}
